using System;
using System.Collections.Generic;
using System.Data;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Hazza.Christmas {
    public class Migrations : DataMigrationImpl {

        public int Create() {
			// Creating table ChristmasPartRecord
			SchemaBuilder.CreateTable("ChristmasPartRecord", table => table
				.ContentPartRecord()
			);

            ContentDefinitionManager.AlterPartDefinition("ChristmasPart", builder => builder.Attachable());

            return 1;
        }

        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterTypeDefinition("ChristmasWidget", cfg => cfg
                .WithPart("ChristmasPart")
                .WithPart("WidgetPart")
                .WithPart("CommonPart")
                .WithSetting("Stereotype", "Widget"));

            return 2;  
        }
    }
}